import Vue from 'vue'
import Router from 'vue-router'
import Home from '../pages/home/Home.vue'
import City from '../pages/city/City.vue'
import Detail from '../pages/detail/Detail.vue'

Vue.use(Router)
// 使用<keep-alive>优化 提示导航重复 下列代码解决
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const RouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
  return RouterPush.call(this, to).catch(err => err)
}
const RouterReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(to) {
  return RouterReplace.call(this, to).catch(err => err)
}

export default new Router({
  routes: [
    {
      path: '/',
      name: "Home",
      component: Home
    },
    {
      path: '/city',
      name: "City",
      component: City
    },
    {
      path:'/detail',
      name:"Detail",
      component:Detail
    }
  ]
})
